package day01;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

/**
 * @author feng
 * @Date 2021/12/26 14:06
 * FileOutputStream:没有文件会创建文件
 * 将数据写入到硬盘
 * 注意:输出流会将原数据覆盖。此时将将追加写为True;
 */
public class FileOutputStreamTest {
    public static void main(String[] args) {
        String filePath = "D:\\IO\\1.text";
        FileOutputStream outputStream = null;
        Byte[] bytes;
        try {
            outputStream = new FileOutputStream(filePath, true);
            String str = "Hello,world!";
            outputStream.write(str.getBytes());
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                outputStream.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}
